package com.lyf.practice.controller;

import com.lyf.practice.dao.jpa.UserDao;
import com.lyf.practice.dao.mybatis.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;

/**
 * @AUTHOR LYF
 * @DATE 2022/5/24
 * @VERSION 1.0
 * @DESC
 */
@Controller
public class RunInitController implements ApplicationRunner {
    @Autowired
    UserDao userDao;
    @Autowired
    UserMapper userMapper;
    @Autowired
    RedisTemplate redisTemplate;
    @Autowired
    MongoTemplate mongoTemplate;
//    @Autowired
//    LoadCondition loadCondition;

    @Override
    public void run(ApplicationArguments args) throws Exception {

       // redisTemplate.opsForValue().get("1");
//        UserBean userBean = new UserBean();
//        userBean.setUserId("1");
//        userBean.setId(12);
//        mongoTemplate.save(userBean);
        redisTemplate.opsForValue().set("test2","hello,redis!");

        userDao.findAll().forEach(u->{
            System.out.println(u);
        });

        userMapper.queryAll().forEach(u->{
            System.out.println(u);
        });
    
        System.out.println();
    }
}
